namespace comp {

    class Vec2D {
        public x: number
        public y: number
    }
    class Vec3D extends Vec2D {
        public z: number
    }

    export class TestScene extends hjc.Scene {
        public joyStick: JoyTable
        public UIGroup: eui.Group
        constructor() {
            super()
        }
        protected created() {
            this.joyStick = new JoyTable()
            this.joyStick.noSkin()
            this.joyStick.start(this.UIGroup)
            game.on(ntf.JoyStickChange, this._joyStickChange, this)
        }
        private _line = new egret.DisplayObjectContainer()
        private _controller = new HorizonController()
        protected displayed() {
            super.displayed()
            console.debug("TestScene.displayed")

            let alpha = new eui.Label();
            alpha.text = "alpha"
            this.UIGroup.addChild(alpha);
            alpha.x = 300;
            alpha.y = 250;

            let beta = new eui.Label();
            beta.text = "beta"
            this.UIGroup.addChild(beta);
            beta.x = 300;
            beta.y = 300;

            let gamma = new eui.Label();
            gamma.text = "gamma"
            this.UIGroup.addChild(gamma);
            gamma.x = 300;
            gamma.y = 350;

            let absolute = new eui.Label();
            absolute.text = "absolute"
            this.UIGroup.addChild(absolute);
            absolute.x = 300;
            absolute.y = 400;
            absolute.addEventListener(egret.TouchEvent.TOUCH_TAP, this._resetBtnClick, this)

            {
                this._line.addChild(ui.drawLine({ x: 0, y: 0, x2: 200, y2: 0 }))
            }
            {
                this._line.addChild(ui.drawCircle({ x: 0, y: 0, radius: 20 }))
            }
            this.UIGroup.addChild(this._line);
            this._line.x = 300;
            this._line.y = 600;

            this._controller.start(90, 1.0)
        }

        private _resetBtnClick(e: egret.TouchEvent) {
            this._controller.reset()
        }

        private _joyStickChange(ntf: hjc.Notification) {
            console.debug(ntf)
            let stick = <GameController>(ntf.source)
            if (stick.Type() == GameControllerKind.HorizonController) {
                this._line.rotation = ntf.data.Angle
            }
        }
    }
}
